package com.mnb.base.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mnb.common.utils.MapKeyUtil;
import com.mnb.common.utils.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.mnb.base.entity.CusOrimes;
import com.mnb.base.mapper.CusOrimesMapper;
import com.mnb.base.service.CusOrimesService;

import java.util.List;
import java.util.Map;

@Service
public class CusOrimesServiceImpl implements CusOrimesService{

    @Resource
    private CusOrimesMapper cusOrimesMapper;


    @Override
    public R getList(CusOrimes cusOrimes) {
        Page page = PageHelper.startPage(cusOrimes.getPageNum(), cusOrimes.getPageSize()).doSelectPage(() -> cusOrimesMapper.getList(cusOrimes));
        R result = R.ok(page.getResult());
        result.setTotal(page.getTotal());
        return result;
    }

    @Override
    public R getOnlineStatus(CusOrimes cusOrimes) {
        List<Map<String, Object>> list = cusOrimesMapper.getOnlineStatus(cusOrimes);
        list = MapKeyUtil.convertKeysToLowerCase(list);
        return R.ok(list);
    }
}
